package com.example.springbootkafka.kafka;

import com.example.springbootkafka.config.KafkaConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * kafka stream的消费者
 *
 * @author huangchangjin
 * @date 2025/1/8 11:30
 */
@Slf4j
@Component
public class StreamConsumer {
    @KafkaListener(topics = KafkaConfig.STREAM_IN_TOPIC)
    public void streamTopicConsumerTopic1(ConsumerRecord<String, String> record) {
        log.info("kafka流式消费 topic = {}, key = {} ,value = {}, header = {}", record.topic(), record.key(), record.value(), record.headers());
    }

    @KafkaListener(topics = KafkaConfig.STREAM_OUT_TOPIC)
    public void streamTopicConsumerTopic2(ConsumerRecord<String, String> record) {
        log.info("kafka流式消费 topic = {}, key = {} ,value = {} , header = {}", record.topic(), record.key(), record.value(), record.headers());
    }
}
